package com.higgins.lawapp.client.settings.components;

import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextBox;
import com.higgins.lawapp.client.settings.model.DataSourceModel;

public class URLField extends DataSourceComponent	{
	private DataSourceModel dataSourceModel;
	private Label label = new Label();
    private TextBox urlTextBox = new TextBox();
    private TextBox exampleUrlField = new TextBox();
    private CheckBox executionCheckBox = new CheckBox();
    private CheckBox concatCheckBox = new CheckBox();
    private int tabNumber;

	public URLField(String fieldName, String text, String fieldExample, DataSourceModel dataSourceModel, int tabNumber, Boolean execution, Boolean concat)	{
		this.dataSourceModel = dataSourceModel;
		this.tabNumber = tabNumber;
	    label.setText(fieldName);
		urlTextBox.setTitle(fieldName);
	    if (text!=null)	
	    	urlTextBox.setText(text);
	    else
	    	urlTextBox.setText("");	 
	    if (fieldExample!=null)
		    exampleUrlField.setText(fieldExample);
	    else
		    exampleUrlField.setText("");
	    executionCheckBox.setValue(execution);
	    executionCheckBox.setText("execute");
	    concatCheckBox.setValue(concat);
	    concatCheckBox.setText("Concat");
	    add(label);
	    add(urlTextBox);
	    add(exampleUrlField);
	    add(executionCheckBox);
	    add(concatCheckBox);
	    setWidgetLeftWidth(label, 0, Unit.PCT, 30, Unit.PCT);
	    setWidgetLeftWidth(urlTextBox, 30, Unit.PCT, 30, Unit.PCT);
	    setWidgetLeftWidth(exampleUrlField, 60, Unit.PCT, 20, Unit.PCT);
	    setWidgetLeftWidth(executionCheckBox, 80, Unit.PCT, 10, Unit.PCT);
	    setWidgetRightWidth(concatCheckBox, 0, Unit.PCT, 10, Unit.PCT);
	}
	public String getDataSourceURL()	{
		return urlTextBox.getText();
	}

	public String getDataSourceURLExampleField()	{
		return exampleUrlField.getText();
	}
	
	public Boolean getExecution()	{
		return executionCheckBox.getValue();
	}
	public Boolean getConcat()	{
		return concatCheckBox.getValue();
	}
}
